package com.example.workflow.mapper;

import com.example.workflow.entity.SysProcess;
import org.apache.ibatis.annotations.*;

import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@Mapper
public interface SysProcessMapper extends BaseMapper<SysProcess> {
    
    @Insert("INSERT INTO sys_process(system_id, process_key, process_name, description, version,del_flag,create_time,update_time,status,deployment_id,process_definition_id) " +
            "VALUES(#{systemId}, #{processKey}, #{processName}, #{description}, #{version},#{delFlag},#{createTime},#{updateTime},#{status},#{deploymentId},#{processDefinitionId})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(SysProcess process);

    @Select("SELECT * FROM sys_process WHERE system_id = #{systemId} AND del_flag = 0")
    List<SysProcess> selectBySystemId(@Param("systemId") Long systemId);

    @Update("UPDATE sys_process SET del_flag = 1 WHERE id = #{id}")
    int delete(Long id);

    @Select("SELECT * FROM sys_process WHERE system_id = #{systemId} AND process_key = #{processKey} AND del_flag = 0")
    SysProcess selectBySystemIdAndKey(@Param("systemId") Long systemId, @Param("processKey") String processKey);
} 